package com.rwy.web.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import com.rwy.web.filter.authorize.UserAuthorizeInterceptor;

import net.sf.ehcache.CacheManager;

@Component
public class IntercaptorRegistration {
   
	@Value("${login_redirect_url}")
	private String login_redirect_url;
	
	@Value("${login_fault_redirect_url}")
	private String login_fault_redirect_url;
	
	@Value("${get_jssdk_ticket}")
	private String get_jssdk_ticket;
	
	@Autowired
	CacheManager cachemanger; 
	
	
	public HandlerInterceptor authorize() {
		UserAuthorizeInterceptor authorize = new UserAuthorizeInterceptor();
		authorize.setRedicect_url(login_redirect_url);
		authorize.setLogin_fault_redirect_url(login_fault_redirect_url);
		authorize.setJs_sdk_ticket_url(get_jssdk_ticket);
		authorize.setCacherManager(cachemanger);
		return authorize;
	}
}
